#include "stdafx.h"
#include "truetype_head.h"
#include "truetype.h"

void truetype_head(truetype_t * tt, tt_table_t * table)
{
	if(!tt || !tt->stream || !table || table->type != tt_table_type_head)
		return ;

	base_stream_t * stream = tt->stream;

	tt_head_t head;
	stream->seeker(stream, table->offset, stream_seek_begin);
	stream->reader(stream, &head, sizeof(tt_head_t));
#ifdef TT_SMALL_ENDIAN
	tt->flags =	confirm_big_word(head.flags);
	tt->unit  =	confirm_big_word(head.unit);
	tt->min_x =	confirm_big_word(head.x_min);
	tt->min_y =	confirm_big_word(head.y_min);
	tt->max_x =	confirm_big_word(head.x_max);
	tt->max_y =	confirm_big_word(head.y_max);
	tt->min_size =	confirm_big_word(head.min_size);
	tt->loca_format = (tt_loca_format_e)confirm_big_short(head.loca_index_format);
#else
	tt->flags = head.flags;
	tt->unit  = head.unit;
	tt->min_x =	head.x_min;
	tt->min_y =	head.y_min;
	tt->max_x =	head.x_max;
	tt->max_y =	head.y_max;
	tt->min_size =	head.min_size;
	tt->loca_format = (tt_loca_format_e)head.loca_index_format;
#endif // TT_SMALL_ENDIAN
}
